package com.wjh.kt_vod.controller;

import com.wjh.kt_vod.model.vod.Video;
import com.wjh.kt_vod.result.Result;
import com.wjh.kt_vod.service.VideoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(tags = "小结管理")
@RestController
@RequestMapping("/admin/vod/video")
public class VideoController {

    @Autowired
    private VideoService videoService;

    @ApiOperation(value = "查找")
    @GetMapping("/get/{id}")
    public Result getVideo(@PathVariable("id") Long id){
        Video byId = videoService.getById(id);
        return Result.ok(byId);
    }

    @ApiOperation(value = "查找")
    @DeleteMapping("/remove/{id}")
    public Result removeVideo(@PathVariable("id") Long id){
        videoService.removeById(id);
        return Result.ok();
    }

    @ApiOperation(value = "修改")
    @PostMapping("/update")
    public Result addVideo(@RequestBody Video video){
       videoService.save(video);
        return Result.ok();
    }

    @ApiOperation(value = "新增")
    @PostMapping("save")
    public Result save(@RequestBody Video video) {
        videoService.save(video);
        return Result.ok(null);
    }



}
